/**
 * @file Vector3.h
 * @author  Aljosa Osep <aljosa.osep@gmail.com, Fletcher Dunn, Ian Parnberry>
 * @version 1.0
 *
 * @section LICENSE
 *
 * Redistribution and use in source and binary forms, with or without modification, are
 * permitted provided that the following conditions are met:

 *  1. Redistributions of source code must retain the above copyright notice, this list of
 *    conditions and the following disclaimer.

 *  2. Redistributions in binary form must reproduce the above copyright notice, this list
 *     of conditions and the following disclaimer in the documentation and/or other materials
 *     provided with the distribution.

 * THIS SOFTWARE IS PROVIDED BY <Aljosa Osep> ``AS IS'' AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <Aljosa Osep>> OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

 * The views and conclusions contained in the software and documentation are those of the
 * authors and should not be interpreted as representing official policies, either expressed
 * or implied, of <Aljosa Osep>.
 *
 * @section DESCRIPTION
 *
 * Vector3 - an 3D vector library header
 * Based on examples from 3D Math Premier of Graphics and Games Development book
 * Original authors: Fletcher Dunn, Ian Parnberry. Thanks!
 */

#ifndef __VECTOR3
#define __VECTOR3

#include <iostream>
#include <cmath>

using namespace std;

namespace xEngine
{
    namespace PlatformIndependent
    {
        namespace Math
        {
            class Vector3
            {
            public:
                float x, y, z;

                Vector3();
                Vector3(const Vector3 &p);
                Vector3(float x, float y, float z);

                // Operators
                Vector3 &operator=(const Vector3 &a);
                bool operator ==(const Vector3& p) const;
                bool operator !=(const Vector3 &a) const;

                // vector operations
                void zero();
                Vector3 operator-() const;
                Vector3 operator-(const Vector3 &p) const;
                Vector3 operator+(const Vector3 &p) const;

                Vector3 operator*(float a) const; // scalar product
                Vector3 operator/(float a) const; // vect division

                Vector3 &operator +=(const Vector3 &a);
                Vector3 &operator -=(const Vector3 &a);
                Vector3 &operator *=(float a);
                Vector3 &operator /=(float a);

                float operator *(const Vector3 &a) const;

                float length();
                void normalize();
                void set(float x, float y, float z);
                float distanceToPoint(const Vector3 &p) const;

            };

            //// Nonmembers
            inline float distance(const Vector3 &a, const Vector3 &b);
            inline float vectorLength(const Vector3 &a);
            inline Vector3 crossProduct(const Vector3 &a, const Vector3 &b);
            inline Vector3 operator *(float k, const Vector3 &v);
        }
    }
}


#endif
